package com.example.androidwearmap;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

/**
 * Created by Administrator on 2015/7/13.
 */
public abstract class BaseMapActivity extends FragmentActivity {
    private GoogleMap mMap;
    protected int getLayoutId() {
        return R.layout.map;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        setUpMapIfNeeded();
    }

    private void setUpMapIfNeeded() {
        if (mMap != null) {
            return;
        }
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        if (mMap != null) {
            start();
        }
    }
    protected abstract void start();
    protected GoogleMap getMap() {
        setUpMapIfNeeded();
        return mMap;
    }
}
